<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" session="true"%>
<jsp:useBean id="chosenCar" class="edu.unsw.comp9321.common.CarBean"
	scope="session"/>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Customer details</title>
		<link href="CSS.css" rel="stylesheet" type="text/css">
	</head>
	<body>
		<div id="pagehdr">
			<h1>Car Rental reservation system</h1>
		</div>
		<%
		if (chosenCar.getCar() == null || chosenCar.getCarType() == null) {
		%>
				<p>Sorry, an error occurred.<br/>Please search again.<p>
				<form action="controller" method="POST">
					<input type="hidden" name="op" value="searchAgain"/>
					<input type="submit" value="Search again">
				</form>
		<%
		} else {
			if (request.getAttribute("violation") != null && !request.getAttribute("violation").equals("noViolation")) {
				out.write("<br/><span style=\"color:red\"><strong>"
					+ request.getAttribute("violation") +"</strong></span><br/><br/>");
			} else {
		%>
		<% 
				out.write("<br/>");
				out.write("<strong>Thanks for renting a "+ chosenCar.getCarType().getMakeModel()+"</strong>");
		%>
			<p>Please enter your details below...</p>
		<%
			}
		%>
			<form action="controller">
				<strong>Name: </strong><input type="text" name="customerName"><br/>
				<strong>Date of birth</strong>: <input name="dateOfBirth" type="date"/><br/>
				<strong>License date</strong>: <input name="licenseDate" type="date"/><br/><br/>
				<strong>Excess:</strong><br/>
				<p>You can elect to reduce your excess by half by paying extra AUD 150 per vehicle.</p>
				<input type="radio" name="excess" value="yes">Yes<br/>
				<input type="radio" name="excess" value="no">No<br/><br/>
				<%
				if (!chosenCar.getCarType().getClass().equals("Midsize Green")) {
				%>
					<strong>Green offset:</strong><br/>
					<p>
						We offer a choice to offset your carbon emissions by paying an extra 2 percent of the 
						vehicle rate daily. However, this is included in the price of the Midsize Green car.
					</p>
					<p>New daily rate would be <strong>$<fmt:formatNumber minFractionDigits="2" maxFractionDigits="2" value="${greenOffsetRate}"/></strong></p>
					<input type="radio" name="greenOffset" value="yes">Yes<br/>
					<input type="radio" name="greenOffset" value="no">No<br/><br/>
				<%
				} else {
				%>
					<p>Green offset (of 2% of daily vehicle rate) is included in the price of the Midsize Green car.</p>
				<%
				}
				%>
				<input type="hidden" name="op" value="checkCustomerDetails"/>
				<input type="submit" value="Continue">
			</form>
		<%
		}
		%>
	</body>
</html>